package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.OrderStatisticsService;
import com.atguigu.spzx.model.entity.order.OrderStatistics;
import com.atguigu.spzx.model.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/order/statistics")
@Tag(name = "订单统计管理模块")
public class OrderStatisticsController {
    @Resource
    OrderStatisticsService orderStatisticsService;
    @Operation(summary = "查询时间区间内的订单统计数据")
    @GetMapping("list/{begin}/{end}")
    public Result list(@PathVariable("begin")String begin , @PathVariable("end")String end){
        // 每天的订单的成交数量，和总金额
        // 直接返回每天的统计数据对象:前端需要遍历处理数据 解析成 需要的每个数据的集合
        // 后端也可以将数据封装为前端需要的结构:
        // List<String> dates ,   2023-07-10   2023-07-11
        // List<Integer> totalNums ,  100       20
        // List<BigDecimal> totalAmounts 1000   200000
        // Map<String,List> map : map.put("dates" , dates)  map.put("totalNums" , totalNums)
        Map<String, List> map =  orderStatisticsService.list(begin,end);
        return Result.ok(map);
    }
}
